#@admin_layout()
#define admin_main()
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
	<legend>完整功能（没错，目前工具栏只有这么多）</legend>
</fieldset>

<textarea class="layui-textarea" id="LAY_demo1" style="display: none">
  把编辑器的初始内容放在这textarea即可
</textarea>

<div class="site-demo-button" style="margin-top: 20px;">
	<button class="layui-btn site-demo-layedit" data-type="content">获取编辑器内容</button>
	<button class="layui-btn site-demo-layedit" data-type="text">获取编辑器纯文本内容</button>
	<button class="layui-btn site-demo-layedit" data-type="selection">获取编辑器选中内容</button>
</div>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
	<legend>自定义工具栏</legend>
</fieldset>

<div style="margin-bottom: 20px; width: 500px;">
	<textarea class="layui-textarea" id="LAY_demo2" style="display: none"></textarea>
</div>

#end

#define admin_script()
<script>
	layui.use('layedit', function(){
		var layedit = layui.layedit
				,$ = layui.jquery;

		//构建一个默认的编辑器
		layedit.set({
			uploadImage: {
				url: '/file/upload'
			}
		});
		var index = layedit.build('LAY_demo1');

		//编辑器外部操作
		var active = {
			content: function(){
				alert(layedit.getContent(index)); //获取编辑器内容
			}
			,text: function(){
				alert(layedit.getText(index)); //获取编辑器纯文本内容
			}
			,selection: function(){
				alert(layedit.getSelection(index));
			}
		};

		$('.site-demo-layedit').on('click', function(){
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});

		//自定义工具栏
		layedit.build('LAY_demo2', {
			tool: ['face', 'link', 'unlink', '|', 'left', 'center', 'right']
			,height: 100
		})
	});
</script>
#end